package com.itheima.service.impl;

import com.itheima.mapper.EmpMapper;
import com.itheima.pojo.vo.JobVo;
import com.itheima.pojo.vo.StuCountVo;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private EmpMapper empMapper;

    @Override
    public JobVo empJobReport() {
        List<Map<String,Object>> list = empMapper.selJobReport();
        List<String> jobList = list.stream().map(jc -> jc.get("job").toString()).toList();
        List<Object> dataList = list.stream().map(jc -> jc.get("count")).toList();
        return new JobVo(jobList,dataList);
    }

    @Override
    public List<Map<String,Object>> empGenderReport() {
        List<Map<String,Object>> genderList = empMapper.selGenderReport();
        return genderList;
    }

    @Override
    public List<Map<String, Object>> studentDegreeReport() {
        List<Map<String,Object>> studentDegreeList = empMapper.selStudentDegreeReport();
        return studentDegreeList;
    }

    @Override
    public StuCountVo studentCountReport() {
        List<Map<String,Object>> list = empMapper.selStudentCountReport();
        List<String> clazzList = list.stream().map(sc -> sc.get("clazzName").toString()).toList();
        List<Object> dataList = list.stream().map(sc -> sc.get("count")).toList();
        return new StuCountVo(clazzList,dataList);
    }
}
